package com.heima.leadnews.user.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dto.ApUserLoginDto;
import com.heima.leadnews.user.service.ApUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/login")
@Api(tags = "登录相关接口")
public class ApUserLoginController {

    @Autowired
    private ApUserService apUserService;

    /**
     * 用户登录
     * @param dto
     * @return
     */
    @ApiOperation("登录")
    @PostMapping("/login_auth")
    public ResponseResult login(@RequestBody ApUserLoginDto dto) {
        //1。接收参数
        //2.调用service完成登录
        //3.返回参数给前端
        return apUserService.login(dto);
    }

    /**
     * test
     * @return
     */
    @ApiOperation("test")
    @PostMapping("/test")
    public String test() {
        //1。接收参数
        //2.调用service完成登录
        //3.返回参数给前端
        return "ok";
    }
}